﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.ComponentModel;

namespace OgilvyOne.Ext.Weibo.Configuration
{
    /// <summary>
    /// Represents the response error handling configuration.
    /// </summary>
    [ConfigurationCollection(typeof(HandlerConfigurationElement), AddItemName = "handler")]
    public class ResponseErrorHandlingConfiguration : ConfigurationElementCollection
    {
        private const string C_Enabled = "enabled";

        /// <remarks/>
        protected override ConfigurationElement CreateNewElement()
        {
            return new HandlerConfigurationElement();
        }

        /// <remarks/>
        protected override object GetElementKey(ConfigurationElement element)
        {
            var handlerConfig = element as HandlerConfigurationElement;

            return handlerConfig.ErrorCode;
        }

        /// <summary>
        /// Gets or sets a boolean value indicating whether the response error handling is enabled.
        /// </summary>
        [ConfigurationProperty(C_Enabled)]
        public bool Enabled
        {
            get
            {
                return (bool)this[C_Enabled];
            }
            set
            {
                this[C_Enabled] = value;
            }
        }
    }
}
